<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
	<s:head theme="ajax"/>	
	<style>
		body, input{
			font-family: Calibri, Arial;
		}
		table#contact {
			border-collapse: collapse;
			width:550px;
		}
		th {
			height: 40px;
			background-color: #ffee55;
		}
	</style>
	<title>Noleggio Manager - Project Live!</title>
</head>
<body>
	<div id="insDiv" class="insDiv">
		<h1> 
			<img class="insDivImg insDivImgOpen" src="images/arr-open.png"/> 
			<span>Inserimento Noleggio</span>
		</h1>
	</div>	
	<s:actionerror/>
	<div id="insBox" class="insBox">
		<s:form action="addNoleggio" method="post" theme="simple">
			<table style="display:none">
				<tr>
					<td>
						<s:label value="Cliente:"/>
						<s:select list="clienti" listKey="id" listValue="nome" name="noleggio.idcliente" headerKey="-1" headerValue=" --- "/>
					</td>
					<td>
						<s:label value="Data Inizio Noleggio:"/>
						<s:datetimepicker name="noleggio.datainizionolo" displayFormat="dd/MM/yyyy" required="true" />
					</td>
					<td>	
					</td>
				</tr>	
				<tr>
					<td>
						<s:label value="Prodotto:"/>
						<s:select list="prodotti" listKey="id" listValue="nome" name="noleggio.idprodotto" headerKey="-1" headerValue=" --- "/>
					</td>
					<td>
						<s:label value="Quantita':"/>
						<s:textfield name="noleggio.qty" size="5"/>
					</td>
					<td>
						<s:form theme="simple">			        
					        <s:submit action="addElemNoleggio" value="Add"/>
					    </s:form>
					</td>
				</tr>
				<tr>
					<td>
						<table id="rounded-corner">
							<tr>
								<th class="width5 textCenter">#</th>
								<th class="textCenter">Prodotto</th>
								<th class="textCenter">Quantita'</th>
							</tr>
							<s:iterator value="prodottiNoleggiati">
							<tr>
								<td class="textCenter"><s:property value="idprodotto"/></td>
								<td class="textCenter"><s:property value="qty"/></td>
								<td>
									 <s:form theme="simple">			        
								        <s:submit action="deleteProdottoNoleggio" value="Remove" onclick="return confirm('Are you sure you want to delete this item?');"/>
								        <s:submit action="displayEdit" value="Edit"/>
								        <s:hidden name="id" value="%{id}"/>
								    </s:form>
								</td>
							</tr>	
							</s:iterator>
						</table>
					</td>
					<td></td>
					<td></td>	
				</tr>
			</table>		
			<s:submit value="Aggiungi Noleggio" align="center"/>
		</s:form>
	</div>	

	</br></br>
	<h2>Noleggio</h2>
	<table id="rounded-corner">
		<tr>
			<th class="width5 textCenter">#</th>
			<th class="textCenter">Cliente</th>
			<th class="textCenter">Prodotto</th>
			<th class="textCenter">Quantita'</th>
			<th class="textCenter">Data Inizio Noleggio</th>
			<th class="width10 textCenter">Elimina</th>
			<th class="width10 textCenter">Modifica</th>
		</tr>
		<s:iterator value="noleggi">
		<tr>
			<td class="textCenter"><s:property value="id"/></td>
			<td class="textCenter"><s:property value="idcliente"/></td>
			<td class="textCenter"><s:property value="idprodotto"/></td>
			<td class="textCenter"><s:property value="qty"/></td>
			<td class="textCenter"><s:property value="datainizionolo"/></td>		
			<td>
				 <s:form theme="simple">			        
			        <s:submit action="deleteNoleggio" value="Remove" onclick="return confirm('Are you sure you want to delete this item?');"/>
			        <s:submit action="displayEdit" value="Edit"/>
			        <s:hidden name="id" value="%{id}"/>
			    </s:form>
			</td>
		</tr>	
		</s:iterator>
	</table>
</body>
</html>